/*
 * @Author: cmd
 * @we_chat: cmd_develop
 * @Date: 2018-12-24 21:20:25
 * @LastEditors: cmd
 * @LastEditTime: 2019-01-07 10:25:22
 * @Description: 提示框管理器：加载中、弹框提示
 */

const {ccclass, property} = cc._decorator;

@ccclass
export default class component_alert extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    start () {

    }

    show_tips(text:string){
        this.node.stopAllActions();
        console.log("text：",text);
        this.label.string = text;
        this.node.setPosition(cc.v2(0,0));
        this.node.opacity = 255;
        this.node.active = true;        
        // this.node.width = text.length*30 + 30;
       
        this.label.scheduleOnce(()=>{
            let fateOut = cc.fadeOut(0.5);
            let moveUp = cc.moveTo(0.5,cc.v2(0,100));
            let swa = cc.spawn(fateOut,moveUp);
            // var finished = cc.callFunc(()=> {
            //     this.node.destroy();
            // });
            // let seq = cc.sequence(swa,finished);
            this.node.runAction(swa);
        },1);
    }

    show_loading(text:string){
        this.node.getChildByName('loading_label').getComponent(cc.Label).string = text;
    }

    close_loading(){
        this.node.active = false;
    }

    // update (dt) {}
}
